Skip to content

typescript: a call to a function-literal const no longer also names its annotation's signature (#2005) - #2027

Merged
swapnilpaliwal-sd merged 3 commits into
0.2.4from
fix/ts-annotated-function-const
Nov 19, 2026
Merged

swapnilpaliwal-sd merged 3 commits into
0.2.4from
fix/ts-annotated-function-const

Conversation

@swapnilpaliwal-sd

Copy link
Copy Markdown
Contributor

Fixes #2005

Summary

A call to a const annotated with a callable type and holding a function literal resolved to two targets, the literal's body and the annotation's bodiless call signature:

export interface Format { (input: string): string }
export const fromArrow: Format = (input) => input;
fromArrow(s);          // body AND Format#<call signature>, multi_inferred
formats.fromArrow(s);  // same

Rule (3) in callee-resolution.dl adds the call signature of the callee's expr_type / expr_shape with no check that the callee already holds a literal. The namespace var_shape clause in expr-type.dl carried that guard; rule (3) did not. Rule (3) now skips a callee that holds a function literal (a local, a named import, or a namespace member read). A const holding a factory's result, and a parameter, keep the signature.

Review these first

  • graph/typescript/engine/expression-resolution/callee-resolution.dl: the !callee_holds_function(ne) guard on both rule (3) clauses, and callee_holds_function. It reads only expr_referenced, import_binds, property_access_recv, expr_namespace, module_export and var_is_function, which are below the expression fixpoint (expr_callable already uses them under a negation), so the negation stays stratifiable.

Tests

  • New case 101-annotated-function-const: the interface and function-type-alias forms, each through a local, a named import and a namespace read, with a factory-result and a parameter control.
    • Base (0.2.4): each of the literal sites is multi_inferred to the body and the signature.
    • Here: each is one known_edge to the body; the controls are unchanged.
  • TypeScript suite with the compiler oracle: 113 passed, 0 failed.
  • Goldens moved, every one the same two-way hedge collapsing to the body:
    • 08 (lib), 63, 65: the compiler names the annotation's signature, so the site is recorded in known-missing, the shape 92 and 98 already accept.
    • 74: a JSX component const typed by a generic callable.
    • 77: an extra edge goes.
    • The comment in case 65 now says what a revert of its arity relaxation looks like, since the body is each cell's one edge.

… keeps its own version)

0.2.3 is released, so what merges into this branch ships in 0.2.4. package.json (version and the five @axiomcode/engine-* pins) and the four editor plugin and extension manifests move from 0.2.3 to 0.2.4. The parser keeps its own version.
@swapnilpaliwal-sd swapnilpaliwal-sd added bug Something isn't working typescript TypeScript engine Resolution / call-graph engine rules labels Nov 18, 2026
…ts annotation's signature (#2005)

A call to a const annotated with a callable type and holding a function
literal resolved two ways: the literal's body and the annotation's bodiless
call signature. Rule (3) in callee-resolution.dl added the signature of the
callee's expr_type or expr_shape with no check that the callee already holds
a literal, which the method lookup answers with its body. The namespace
var_shape clause in expr-type.dl carried that guard; rule (3) did not.

Rule (3) now skips a callee that holds a function literal
(callee_holds_function): a local, a named import, or a namespace member read.
The relation is built from relations below the expression fixpoint, so the
negation stays stratifiable. A const holding a factory's result, and a
parameter, keep the signature as the target.

Case 101 pins the interface and function-type-alias forms through a local,
a named import and a namespace read, with factory and parameter controls.
On the base each literal site is multi_inferred to body and signature; here
each is one known_edge to the body.

Goldens: the same two-way hedge collapses to the body in 08 (lib), 63, 65,
74 and 77. The compiler names the annotation's signature, so 08, 63 and 65
record it in known-missing, the shape 92 and 98 already accept; 77 loses
an extra. The comment in case 65 describes what a revert now looks like.
@swapnilpaliwal-sd
swapnilpaliwal-sd merged commit 2a5373e into 0.2.4 Nov 19, 2026
13 checks passed
@swapnilpaliwal-sd
swapnilpaliwal-sd deleted the fix/ts-annotated-function-const branch November 19, 2026 04:31
@swapnilpaliwal-sd swapnilpaliwal-sd mentioned this pull request Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working engine Resolution / call-graph engine rules typescript TypeScript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant